package com.dingaolin.concurrencystudy.concurrencyknowledge.threadcoreknowledge;

/**
 * @author dingaolin
 * @Date: 2020/2/17 0017.
 */
public class Test {

    static class CountRunnable implements Runnable {

        int num;
        int total;

        public CountRunnable(int num, int total) {
            this.num = num;
            this.total = total;
        }

        @Override
        public void run() {
            if (num <= total && num %2 == 0) {
                System.out.println("偶线程" + Thread.currentThread().getName() + " 打印 " + num);
                num++;
            } else {
                System.out.println("偶线程" + Thread.currentThread().getName() + " 打印 " + num);
                num++;
            }
        }
    }

    public static void main(String[] args) {
        int num = 0;
        int total = 100;

        Thread t0 = new Thread(new CountRunnable(num, total));
        t0.start();
    }
}
